#include "normalplaylistmodel.h"

NormalPlayListModel::NormalPlayListModel()
{
}

NormalPlayListModel::~NormalPlayListModel()
{

}

void NormalPlayListModel::setSongs(EZTally::EZTallyArray<SongModel*> *newSongs)
{
    newSongs->Retain();
    if(this->songs)
        this->songs->Release();
    this->songs = newSongs;
    this->setCurIndex(0);
    emit sigPlayQueueTypeChange();
}
void NormalPlayListModel::addSong(SongModel *song)
{
    if(this->songs == 0){
        this->songs = new EZTally::EZTallyArray<SongModel*>();
    }
    this->songs->AddObject(song);


    for(int i=0;i<_listDelegate.count();i++){
        PlayListBaseModelDelegate *delegate = _listDelegate.at(i);
        delegate->onSongChange(this,0);
    }
//    EZTally::EZTallyAutoPtr ptr; //本来要发的,但是我不想用通知发这个,没原因,你想就把注悉去掉
//    emit songsChange(ptr);
}

void NormalPlayListModel::removeSong(SongModel *song)
{
    if(this->songs==0){
        return;
    }
    this->songs->RemoveObject(song);

    for(int i=0;i<_listDelegate.count();i++){
        PlayListBaseModelDelegate *delegate = _listDelegate.at(i);
        delegate->onSongChange(this,0);
    }
//    EZTally::EZTallyAutoPtr ptr; //本来要发的,但是我不想用通知发这个,没原因,你想就把注悉去掉
//    emit songsChange(ptr);
}

void NormalPlayListModel::removeSongAtIndex(int index)
{
    this->songs->RemoveObjectAtIndex(index);

    for(int i=0;i<_listDelegate.count();i++){
        PlayListBaseModelDelegate *delegate = _listDelegate.at(i);
        delegate->onSongChange(this,0);
    }
//    EZTally::EZTallyAutoPtr ptr; //本来要发的,但是我不想用通知发这个,没原因,你想就把注悉去掉
//    emit songsChange(ptr);
}
